#include <bits/stdc++.h>
// 2025/01/20
// tag:
// Author: Zhang Muen
using namespace std;

struct node
{
    int cnt;
    node *next[2];
    int mustuse_mask[2];
    node() : cnt(-1)
    {
        mustuse_mask[0] = mustuse_mask[1] = -1;
        next[0] = next[1] = nullptr;
    }
};

int n, ans;
int input[1001];

void mustuse(node *tree)
{
    if (tree == nullptr)
        return;
    if (tree->cnt != -1)
        return;
    mustuse(tree->next[0]);
    mustuse(tree->next[1]);
    if (tree->next[1] == nullptr)
    {
        tree->mustuse_mask[0] = tree->next[0]->mustuse_mask[0];
        tree->mustuse_mask[1] = tree->next[0]->mustuse_mask[1];
        return;
    }
    if (tree->next[0] == nullptr)
    {
        tree->mustuse_mask[0] = tree->next[1]->mustuse_mask[0];
        tree->mustuse_mask[1] = tree->next[1]->mustuse_mask[1];
        return;
    }
    // Find intersection
    for (int i = 0; i < 2; i++)
    {
        tree->mustuse_mask[i] = -1;
        for (int j = 0; j < 2; j++)
        {
            if (tree->next[0]->mustuse_mask[i] == tree->next[1]->mustuse_mask[j])
            {
                tree->mustuse_mask[i] = tree->next[0]->mustuse_mask[i];
                break;
            }
        }
    }
}

int dfs(node *tree, int x)
{
    node *current = tree;
    for (int i = 30; i >= 0; i--)
    {
        bool v = !((input[x] >> i) & 1);
        if (current->next[v] && (current->next[v]->mustuse_mask[0] != x) && (current->next[v]->mustuse_mask[1] != x))
        {
            current = current->next[v];
        }
        else
        {
            current = current->next[!v];
        }
    }
    return current->cnt ^ input[x];
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> input[i];

    node *tree = new node();

    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            node *p = tree;
            int s = input[i] + input[j];
            for (int k = 30; k >= 0; k--)
            {
                int bit = (s >> k) & 1;
                if (!p->next[bit])
                    p->next[bit] = new node();
                p = p->next[bit];
            }
            p->cnt = s;
            p->mustuse_mask[0] = i;
            p->mustuse_mask[1] = j;
        }
    }

    mustuse(tree);
    for (int i = 1; i <= n; i++)
        ans = max(ans, dfs(tree, i));

    cout << ans << endl;
    return 0;
}